#ifndef HTTPRESPONSE_H
#define HTTPRESPONSE_H

#define HTTPVersion "HTTP/1.1"
#define SERVER "zuchongzhi-1.1"

//status code
//information 1xx
#define STAT100 "100 Continue"
#define STAT101 "101 Switch Protocols"
//successful 2xx
#define STAT200 "200 OK"
#define STAT201 "201 Created"
#define STAT202 "202 Accepted"
#define STAT203 "203 Non-Authoritative Information"
#define STAT204 "204 No Content"
#define STAT205 "205 Reset Content"
#define STAT206 "206 Partial Content"
//redirect 3xx
#define STAT300 "300 Multiple Choices"
#define STAT301 "301 Moved Permanently"
#define STAT302 "302 Found"
#define STAT303 "303 See Other"
#define STAT304 "304 Not Modified"
#define STAT305 "305 Use Proxy"
#define STAT307 "307 Temporary Redirect"
//Client Error 4xx
#define STAT400 "400 Bad Request"
#define STAT401 "401 Unauthorized"
#define STAT402 "402 Payment Required"
#define STAT403 "403 Forbidden"
#define STAT404 "404 Not Found"
#define STAT405 "405 Method Not Allowed"
#define STAT406 "406 Not Acceptable"
#define STAT407 "407 Proxy Authentication Required"
#define STAT408 "408 Request Timeout"
#define STAT409 "409 Conflict"
#define STAT410 "410 Gone"
#define STAT411 "411 Length Required"
#define STAT412 "412 Precondition Failed"
#define STAT413 "413 Request Entity Too Large"
#define STAT414 "414 Request-URI Too Long"
#define STAT415 "415 Unsupported Media Type"
#define STAT416 "416 Requested Range Not Satisfiable"
#define STAT417 "417 Expectation Failed"
//Server Error 5xx
#define STAT500 "500 Internal Server Error"
#define STAT501 "501 Not Implemented"
#define STAT502 "502 Bad Gateway"
#define STAT503 "503 Service Unavailable"
#define STAT504 "504 Gateway Timeout"
#define STAT505 "505 HTTP Version Not Supported"

#define CTYPE_HTML 0
#define CTYPE_GIF 1
#define CTYPE_JPEG 2
#define CTYPE_BMP 3
#define CTYPE_PJPEG 4
#define CTYPE_SWF 5
#define CTYPE_PLAIN 6
#define CTYPE_OCTEC 7
#define CTYPE_JS 8
#define CTYPE_CSS 9
#define CTYPE_SOAPXML 10
#define CTYPE_XML 11
#define CTYPE_MP4 20
#define CTYPE_WMV 21
#define CTYPE_RMV 22

typedef struct {
	//status line
	char HeadCmd[64];
	//general header
	char Cache_Control[64];
	char Connection[64];
	char Date[64];
	char Pragma[64];
	char Trailer[128];
	char Transfer_Encoding[64];
	char Upgrade[64];
	char Via[64];
	char Warning[64];
	//response head
	char Accept_Ranges[64];
	char Age[64];
	char ETag[64];
	char Location[64];
	char Proxy_Authenticate[64];
	char Retry_After[64];
	char Server[64];
	char Vary[64];
	char WWW_Authenticate[64];
	//entity header
	char Allow[64];
	char Content_Encoding[64];
	char Content_Language[64];
	char Content_Length[64];
	char Content_Location[64];
	char Content_MD5[64];
	char Content_Range[64];
	char Content_Type[64];
	char Expires[64];
	char Last_Modified[64];
	//extension header      
	char Keep_Alive[64];

}struHttpResponse, HttpResponse;

HttpResponse *HttpResponseNew(void);//int responsecode,int contentlength,int timeout)
int HttpResponseDelete(HttpResponse *res);
int HttpResponseSetStatusCode(HttpResponse *res, int code, char *discrp);
int HttpResponseSetConnection(HttpResponse *res, char *connstr); //keep-Alive/close
int HttpResponseSetDate(HttpResponse *res);
int HttpResponseSetETag(HttpResponse *res, char * etag);
int HttpResponseSetServer(HttpResponse *res, char *server);
int HttpResponseSetContentLength(HttpResponse *res, int cl);
int HttpResponseSetContentType(HttpResponse *res, char *ct);
int HttpResponseSetWWWAuthen(HttpResponse *res, char *aumode, char *realm);
int HttpResponseSetLastModified(HttpResponse *res);
int HttpResponseSetKeepAlive(HttpResponse *res, int timeout);
int HttpResponseGetResponseHead(HttpResponse *res, char *headstring);
int HttpResponseSetResponseHead(HttpResponse *res, int code, char *descript,int cl, char *filepath);
int HttpResponseGetContentType(char *filepath);
int HttpResponseSetCacheControl(HttpResponse *res, char *value);
int HttpResponseSetPragma(HttpResponse *res, char *value);
int HttpResponseSetExpires(HttpResponse *res, char *value);

#endif

